import MLRequest from './require'
import { BASE_URL1 } from './config'

const $api1 = new MLRequest({
  baseURL: BASE_URL1,
  interceptors: {
    requestSuccessFn: (req) => {
      console.log('$api1的请求成功拦截')
      return req
    },
    requestFailureFn: (err) => {
      console.log('$api1的请求失败拦截')
      return err
    },
    responeseSuccessFn: (res) => {
      console.log('$api1的响应成功拦截')
      return res.data
    },
    responeseFailureFn: (err) => {
      console.log('$api1的响应失败拦截')
      return err
    }
  }
})

const $api2 = new MLRequest({
  baseURL: BASE_URL1,
  interceptors: {
    requestSuccessFn: (req) => {
      console.log('$api2的请求成功拦截')
      return req
    },
    requestFailureFn: (err) => {
      console.log('$api2的请求失败拦截')
      return err
    },
    responeseSuccessFn: (res) => {
      console.log('$api2的响应成功拦截')
      return res.data
    },
    responeseFailureFn: (err) => {
      console.log('$api2的响应失败拦截')
      return err
    }
  }
})

export { $api1, $api2 }
